//
//  MCReleaseMarketingViewController.swift
//  StoreManage
//
//  Created by MC on 2018/6/27.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit
import SDWebImage

class MCReleaseMarketingViewController: MCViewController {

    public var activityLogId = 0
    
    public var dataDict = NSDictionary()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        baseSetting()
        
        initUI()
        
        managerClosure()
        
        sendNetworking()
    }
    
    // MARK: - System Delegate
    
    // MARK: - Custom Delegate
    
    // MARK: - Closure
    func managerClosure() { }
    
    // MARK: - Action
    @objc func lookButtonClicked() {
        let vc = MCDistributionPageViewController()
        MCPushToViewController(current: self, target: vc, isHiddenBottomBarWhenBack: true)
    }
    
    @objc func shareButtonClicked() {

        let vc = MCShareMarketingViewController()
        vc.dataDict = dataDict
        vc.activityLogId = activityLogId
        MCPushToViewController(current: self, target: vc)
    }
    
    // MARK: - Network
    func sendNetworking() {

    }
    
    // MARK: - Method
    func baseSetting() {
        self.title = "发起成功"
        view.backgroundColor = UIColor.MCGray_light
    }
    
    func initUI() {
        view.addSubview(bgView)
        bgView.snp.remakeConstraints { (make) ->Void in
            make.left.right.top.equalTo(view)
            make.height.equalTo(313)
        }
        
        bgView.addSubview(statusImageView)
        statusImageView.snp.remakeConstraints { (make) ->Void in
            make.centerX.equalTo(bgView)
            make.size.equalTo(CGSize.init(width: 100, height: 100))
            make.top.equalTo(50)
        }
        
        bgView.addSubview(promptLabel)
        promptLabel.snp.remakeConstraints { (make) ->Void in
            make.centerX.equalTo(bgView)
            make.top.equalTo(statusImageView.snp.bottom).offset(30)
        }
        
        let width = (MCScreenWidth - 45 * 3) / 2
        
        bgView.addSubview(lookButton)
        lookButton.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(45)
            make.size.equalTo(CGSize.init(width: width, height: 36))
            make.top.equalTo(promptLabel.snp.bottom).offset(50)
        }
        
        bgView.addSubview(shareButton)
        shareButton.snp.remakeConstraints { (make) ->Void in
            make.right.equalTo(-45)
            make.size.equalTo(CGSize.init(width: width, height: 36))
            make.top.equalTo(promptLabel.snp.bottom).offset(50)
        }
    }
    
    // MARK: - Setter & Getter
    
    lazy var bgView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.white
        return view
    }()
    
    lazy var statusImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = #imageLiteral(resourceName: "SweepPay_success").MCImageWithTintMainColor()
        return imageView
    }()
    
    lazy var promptLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(18)
        label.text = "恭喜您，成功发起分销！"
        label.textColor = UIColor.MCMain
        return label
    }()
    
    lazy var lookButton: UIButton = {
        let button = UIButton.init(type: UIButtonType.custom)
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 18
        button.layer.borderColor = UIColor.MCMain.cgColor
        button.layer.borderWidth = 1
        button.titleLabel?.font = MCFont(15)
        button.setTitle("查看我的分销", for: .normal)
        button.setTitleColor(UIColor.MCMain, for: .normal)
        button.addTarget(self, action: #selector(lookButtonClicked), for: .touchUpInside)
        return button
    }()
   
    lazy var shareButton: UIButton = {
        let button = UIButton.init(type: UIButtonType.custom)
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 18
        button.backgroundColor = UIColor.MCMain
        button.titleLabel?.font = MCFont(15)
        button.setTitle("分享", for: .normal)
        button.setTitleColor(UIColor.white, for: .normal)
        button.addTarget(self, action: #selector(shareButtonClicked), for: .touchUpInside)

        return button
    }()

    
}
